<template>
  <div class="child">
    <button @click="handleDispatch">派发事件</button>
    <ul>
      <li v-for="item in pagenation" :key="item">{{ item }}</li>
    </ul>
  </div>
</template>
<script>
import Emitter from '@/mixins/emitter.js'
export default {
  name: 'child',
  mixins: [ Emitter ],
  inject: ['parentCom','pagenation', 'name'],
  created() {
    this.$on('on-message', (text) => {
      console.log('监听父级', text)
    })
  },
  methods: {
    handleDispatch () {
      this.pagenation.push('动态添加')
      this.parentCom.changeName('移动端')
      this.dispatch('parent', 'on-msg', '父级传递数据')
      console.log('派发事件', this.$parent, 'pagenation', this.pagenation)
    }
  }
}
</script>